class Solution:
    def findNumberIn2DArray(self, matrix: List[List[int]], target: int) -> bool:
        if not matrix or not matrix[0]:
            return False
        w=len(matrix[0])
        h=len(matrix)
        x=0
        y=w-1
        while x<h and y>=0:
            if matrix[x][y]<target:
                x+=1
            elif matrix[x][y]>target:
                y-=1
            else:
                return True
        return False